package com.broad.commerce.code.common;

import com.broad.commerce.common.utils.core.StringUtils;
import org.apache.commons.io.filefilter.AbstractFileFilter;
import org.apache.commons.io.filefilter.IOFileFilter;

import java.io.File;
import java.io.Serializable;

/**
 * @author stephen
 * @version V1.0
 * @date 2022-04-17 11:17
 * @description: CustomizeFileFilter
 **/
public class CustomizeFileFilter extends AbstractFileFilter implements Serializable {

	public static final IOFileFilter INSTANCE = new CustomizeFileFilter();
	private static final long serialVersionUID = 3393386136856313184L;

	/**
	 * Restrictive constructor.
	 */
	protected CustomizeFileFilter() {
	}

	/**
	 * Checks to see if the file is a file.
	 * @param file the File to check
	 * @return true if the file is a file
	 * 筛选出项目文件夹下所有的 pom.xml 文件
	 */
	@Override
	public boolean accept(final File file) {
		return file.isFile() && StringUtils.equals(file.getName(), "pom.xml");
	}
}
